<?php
// 服务器环境检查脚本

echo "服务器环境检查\n";
echo "================\n";

// 检查PHP版本
echo "PHP版本: " . PHP_VERSION . "\n";

// 检查SAPI
echo "SAPI: " . PHP_SAPI . "\n";

// 检查关键函数
echo "关键函数检查:\n";
$functions = ['curl_init', 'json_encode', 'ob_get_level', 'flush', 'ob_flush', 'ob_end_clean'];
foreach ($functions as $func) {
    echo "  $func: " . (function_exists($func) ? '存在' : '不存在') . "\n";
}

// 检查输出缓冲设置
echo "\n输出缓冲设置:\n";
echo "  output_buffering: " . ini_get('output_buffering') . "\n";
echo "  zlib.output_compression: " . ini_get('zlib.output_compression') . "\n";
echo "  implicit_flush: " . ini_get('implicit_flush') . "\n";

// 检查当前输出缓冲级别
echo "\n当前输出缓冲级别: " . ob_get_level() . "\n";

// 检查cURL版本
if (function_exists('curl_version')) {
    $curl_info = curl_version();
    echo "\ncURL信息:\n";
    echo "  版本: " . $curl_info['version'] . "\n";
    echo "  SSL版本: " . $curl_info['ssl_version'] . "\n";
    echo "  支持的协议: " . implode(', ', $curl_info['protocols']) . "\n";
}

// 检查FastCGI函数
echo "\nFastCGI支持:\n";
echo "  fastcgi_finish_request: " . (function_exists('fastcgi_finish_request') ? '存在' : '不存在') . "\n";

echo "\n检查完成\n";